//有序数组的平方 力扣977
//对撞指针
class Solution {
public:
	vector<int> sortedSquares(vector<int>& nums) {
		vector<int> arr(nums.size(),0);
		int l = 0;
		int r = nums.size()-1;
		int k = r;
		while(k>=0)
		{
			if(nums[r]*nums[r] >= nums[l]*nums[l])
			{
				arr[k] = nums[r]*nums[r];
				r--;
			}
			else
			{
				arr[k] = nums[l]*nums[l];
				l++;
			}
			k--;
		}
		return arr;
	}
};
